Skip to content

Conversation

@GabrielePicco
Copy link
Collaborator

@GabrielePicco GabrielePicco commented Dec 7, 2025

Description

Implements MIMD 0013

Summary by CodeRabbit

  • New Features

    • Support for SPL Token ATAs and Ephemeral ATAs (eATAs), public helpers to derive/inspect ATAs/eATAs, conversion utilities, and automatic remapping of delegated ATAs to eATAs.
  • Tests

    • New unit and integration tests covering ATA/eATA replacement, remapping, delegation, undelegation, and schedule-commit behavior.
  • Chores

    • Updated package metadata and workspace dependencies (added SPL token libs), added CI lint target, and improved airdrop retry logic.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 7, 2025

📝 Walkthrough

Walkthrough

Adds ATA/eATA support and remapping across the codebase: new token_programs module in magicblock-core (ATA/eATA PDA derivation, ATA inspection, EphemeralAta and conversion helpers); workspace additions for spl-token and spl-token-2022; chainlink fetch/cloner changes to detect, subscribe to, and clone ATAs and derive/handle eATAs (including delegated paths); remapping of delegated SPL ATAs to eATAs in scheduling/commit paths (programs/magicblock); test helpers and integration tests for ATA↔eATA replacement; and package/manifest metadata updates. No public API signatures were changed.

Possibly related PRs

Suggested reviewers

  • thlorenz
  • Dodecahedr0x
  • bmuddha
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/clone-eata

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53461a0 and ffc3e34.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • Cargo.toml (3 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • Cargo.toml
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • Cargo.toml
🔇 Additional comments (3)
Cargo.toml (3)

204-207: Update SPL token dependencies to latest stable versions.

The pinned versions (7.0) are outdated. Latest stable versions are spl-token 9.0.0 and spl-token-2022 10.0.0, which provide better Solana 2.2.x compatibility and include latest maintenance updates. Token-2022 has been audited multiple times with all audits published, and no known security vulnerabilities exist for either package at current versions.


85-85: Verify the git revision and feature compatibility.

The magic-domain-program dependency has been updated to a new revision (cffcfeb) and now uses the modular-sdk feature with default features disabled. Ensure that:

  • The new revision exists and is stable
  • The modular-sdk feature is compatible with the codebase
  • Disabling default features doesn't break existing functionality

98-100: Feature change from "no-entrypoint" to "sdk" is correctly configured.

The magicblock-delegation-program dependency update to revision 1bcaf4d with sdk feature (default-features disabled) is intentional. The workspace default specifies sdk for the main validator runtime, while individual test and dev-dependency crates that require no-entrypoint explicitly override it in their own Cargo.toml files (test-tools, test-schedule-intent, test-committor-service, etc.). The delegation program is accessed through the ephemeral_rollups_sdk abstraction layer, and all call sites remain compatible with this configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@GabrielePicco GabrielePicco changed the title Feat/clone eata Feat: native SPL support Dec 7, 2025
@GabrielePicco GabrielePicco marked this pull request as ready for review December 8, 2025 08:06
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Manual Deploy Available

You can trigger a manual deploy of this PR branch to testnet:

Deploy to Testnet 🚀

Alternative: Comment /deploy on this PR to trigger deployment directly.

⚠️ Note: Manual deploy requires authorization. Only authorized users can trigger deployments.

Comment updated automatically when the PR is synchronized.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 128148f and 00d6f19.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/packages/npm-package/package.json (1 hunks)
  • .github/packages/npm-package/package.json.tmpl (1 hunks)
  • magicblock-chainlink/Cargo.toml (2 hunks)
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs (10 hunks)
  • magicblock-chainlink/src/testing/eatas.rs (1 hunks)
  • magicblock-chainlink/src/testing/mod.rs (1 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2 hunks)
  • test-integration/Cargo.toml (1 hunks)
  • test-integration/test-chainlink/Cargo.toml (1 hunks)
  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (17)
📓 Common learnings
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • test-integration/Cargo.toml
  • test-integration/test-chainlink/Cargo.toml
  • .github/packages/npm-package/package.json.tmpl
  • .github/packages/npm-package/package.json
  • magicblock-chainlink/Cargo.toml
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.

Applied to files:

  • test-integration/test-chainlink/Cargo.toml
  • magicblock-chainlink/Cargo.toml
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.

Applied to files:

  • .github/packages/npm-package/package.json.tmpl
  • .github/packages/npm-package/package.json
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • .github/packages/npm-package/package.json.tmpl
  • .github/packages/npm-package/package.json
📚 Learning: 2025-10-27T09:55:17.808Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:296-298
Timestamp: 2025-10-27T09:55:17.808Z
Learning: In the magicblock-validator codebase, it is acceptable to log API keys in debug/info statements because logs are private and the team considers API keys not that sensitive in their security model.

Applied to files:

  • .github/packages/npm-package/package.json.tmpl
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/testing/eatas.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/testing/mod.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
🧬 Code graph analysis (2)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (4)
magicblock-chainlink/src/remote_account_provider/remote_account.rs (3)
  • owner (54-60)
  • owner (260-262)
  • data (71-77)
magicblock-magic-program-api/src/args.rs (1)
  • data (26-28)
programs/magicblock/src/mutate_accounts/account_mod_data.rs (1)
  • data (137-144)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (142-145)
test-integration/test-chainlink/tests/ix_ata_eata_replace.rs (2)
magicblock-chainlink/src/testing/eatas.rs (4)
  • create_ata_account (34-57)
  • create_eata_account (59-79)
  • derive_ata (18-24)
  • derive_eata (26-32)
magicblock-chainlink/src/remote_account_provider/remote_account.rs (1)
  • delegated (95-101)
🔇 Additional comments (20)
test-integration/test-chainlink/Cargo.toml (1)

25-25: LGTM!

The workspace dependency addition for spl-token aligns with the broader ATA/eATA test support introduced in this PR.

.github/packages/npm-package/package.json.tmpl (1)

7-10: LGTM!

Repository and bugs URLs correctly updated to reflect the rename from ephemeral-validator to magicblock-validator.

magicblock-chainlink/Cargo.toml (1)

24-35: LGTM!

The new dependencies (solana-program, spl-token, spl-token-2022) appropriately enable the ATA/eATA support functionality introduced in this PR. Using workspace versions ensures consistency across the codebase.

.github/packages/npm-package/package.json (1)

5-11: LGTM!

All metadata URLs consistently updated to reference magicblock-validator repository.

magicblock-chainlink/src/testing/mod.rs (1)

9-12: LGTM!

The new eatas module is properly gated with #[cfg(any(test, feature = "dev-context"))], consistent with other testing modules in this file.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)

39-64: LGTM!

The program ID constants and PDA derivation functions are correctly defined. The derive_ata uses the standard ATA seeds ([owner, SPL_TOKEN_PROGRAM_ID, mint] with ASSOCIATED_TOKEN_PROGRAM_ID), and derive_eata uses the eATA program's seeds ([owner, mint] with EATA_PROGRAM_ID).


244-248: LGTM!

The target_pubkey (potentially remapped to eATA) is correctly used when constructing the CommittedAccount, ensuring that commits/undelegates target the appropriate address.

test-integration/Cargo.toml (1)

92-92: Version compatibility confirmed; no action required.

The exact version pin spl-token = "=7.0" is compatible with solana-sdk 2.2 and aligns with the Solana 2.x ecosystem. This pinning strategy ensures reproducible builds across the workspace.

test-integration/test-chainlink/tests/ix_ata_eata_replace.rs (4)

1-12: LGTM!

Imports are appropriate for the test scenarios. The use of ReadableAccount and Pack traits are correctly imported for SPL token account handling.


15-72: LGTM!

Test correctly verifies that when an eATA is delegated to the validator, the cloned ATA account is populated with the eATA's data. The assertions cover all relevant token account fields including mint, amount, owner, close_authority, state, delegated_amount, is_native, and the delegated flag.


74-108: LGTM!

Good negative test case. Correctly verifies that without a delegation record, the cloned ATA retains its original data and is not marked as delegated.


110-161: LGTM!

Good edge case test. Correctly verifies that when the eATA is delegated to a different validator (not ours), the cloned ATA retains its original data and is not marked as delegated.

magicblock-chainlink/src/testing/eatas.rs (4)

18-24: LGTM!

The ATA derivation uses the correct seeds [owner, SPL_TOKEN_PROGRAM_ID, mint] per the SPL Associated Token Program specification.


26-32: LGTM!

The eATA derivation correctly uses seeds [owner, mint] with the EATA program ID, matching the derivation in fetch_cloner.rs.


34-57: LGTM!

The function correctly creates a mock SPL Token account with proper initialization using SplAccount::pack and calculates minimum rent-exempt lamports.


59-79: LGTM!

The eATA account creation correctly matches the expected data layout (owner 32B + mint 32B + amount 8B) that fetch_cloner.rs::maybe_into_ata parses. The conditional owner selection based on delegate flag correctly distinguishes delegated vs. non-delegated eATAs.

magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)

16-20: LGTM!

New imports for SPL token handling are appropriate: Account, COption, Pack, Rent, and SplAccount/AccountState for constructing token accounts.


669-763: LGTM!

The account categorization logic cleanly integrates ATA detection. ATAs are properly separated into their own category for special handling downstream, following the existing pattern for delegated accounts and programs.


3331-3394: LGTM!

The is_ata function correctly:

  1. Validates account ownership (SPL Token or Token-2022)
  2. Checks minimum data length before parsing
  3. Extracts mint and owner from the standard SPL token account layout
  4. Verifies the account pubkey matches the derived ATA address

This ensures only valid ATAs are detected.


3396-3409: LGTM!

The eATA derivation correctly uses try_find_program_address with seeds [owner, mint] and returns Option to safely handle potential derivation failures.

Copy link
Contributor

@taco-paco taco-paco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs similiar implementation for ScheduleBaseIntent case as it also contains committed accounts.

Also an interesting discussion:
Shall we implement such mappings on smart contract level or in "prepocessing" in ScheduledCommitsProcessorImpl?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (7)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)

196-205: Replace unreachable fallback with .expect() for clarity.

The try_into() calls on lines 197-204 cannot fail because data.len() >= 64 (line 194) guarantees the slices are exactly 32 bytes. The fallback to [0u8; 32] is dead code and obscures this invariant.

Apply this diff:

-                    let mint =
-                        Pubkey::new_from_array(match data[0..32].try_into() {
-                            Ok(a) => a,
-                            Err(_) => [0u8; 32],
-                        });
-                    let wallet_owner =
-                        Pubkey::new_from_array(match data[32..64].try_into() {
-                            Ok(a) => a,
-                            Err(_) => [0u8; 32],
-                        });
+                    let mint = Pubkey::new_from_array(
+                        data[0..32].try_into().expect("slice is 32 bytes")
+                    );
+                    let wallet_owner = Pubkey::new_from_array(
+                        data[32..64].try_into().expect("slice is 32 bytes")
+                    );
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (1)

268-282: Clarify or fix the 72-byte allocation.

The helper allocates 72 bytes but the comment states only the first 64 bytes (32 for mint + 32 for owner) are needed. Either reduce to vec![0u8; 64] or explain why the extra 8 bytes are necessary.

Apply this diff if the extra bytes are not needed:

-        let mut data = vec![0u8; 72];
+        let mut data = vec![0u8; 64];
magicblock-chainlink/src/testing/eatas.rs (1)

57-66: Consider consolidating EphemeralAta definition.

This struct appears to be duplicated in fetch_cloner.rs (lines 3414-3421). Consider moving it to a shared location to maintain a single source of truth.

magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)

1107-1194: Critical: eATA subscriptions are never cleaned up.

At line 1122, the code subscribes to the derived eATA pubkey, but this subscription is never added to delegated_acc_subs or any other cleanup structure. When the ATA handling fails or the eATA is not delegated to this validator, these subscriptions remain active indefinitely, causing a subscription leak.

Track eATA subscriptions and cancel them when appropriate:

         if !atas.is_empty() {
             let mut ata_join_set = JoinSet::new();
+            let mut eata_subs = Vec::new();

             // Subscribe first so subsequent fetches are kept up-to-date
             for (ata_pubkey, _, ata_info, slot_for_ata) in &atas {
                 let _ = self.subscribe_to_account(ata_pubkey).await;
                 if let Some((eata, _)) = try_derive_eata_address_and_bump(
                     &ata_info.owner,
                     &ata_info.mint,
                 ) {
                     let _ = self.subscribe_to_account(&eata).await;
+                    eata_subs.push(eata);

                     // ... existing spawn logic ...
                 }
             }

             let ata_results = ata_join_set.join_all().await;
+            let mut eatas_to_cancel = HashSet::new();
+
             for res in ata_results.into_iter() {
                 match res {
                     Ok(Ok(AccountWithCompanion {
                         pubkey: ata_pubkey,
                         account: ata_account,
                         companion_pubkey: eata_pubkey,
                         companion_account: maybe_eata_account,
                     })) => {
                         // ... existing conversion logic ...
+                        
+                        // If we didn't convert the eATA, cancel its subscription
+                        if maybe_eata_account.is_none() || !account_to_clone.delegated() {
+                            eatas_to_cancel.insert(eata_pubkey);
+                        }
                     }
                     Ok(Err(err)) => {
                         warn!("Failed to resolve ATA/eATA companion: {err}");
+                        // Cancel eATA subscription on error
                     }
                     Err(join_err) => {
                         warn!("Failed to join ATA/eATA fetch task: {join_err}");
                     }
                 }
             }
+
+            // Cancel eATA subscriptions that weren't used
+            if !eatas_to_cancel.is_empty() {
+                cancel_subs(
+                    &self.remote_account_provider,
+                    CancelStrategy::All(eatas_to_cancel),
+                )
+                .await;
+            }
         }

3423-3451: Use From instead of Into for better ergonomics.

Implementing From<EphemeralAta> for AccountSharedData is preferred over Into and will automatically provide the Into trait via blanket implementation.

-impl Into<AccountSharedData> for EphemeralAta {
-    fn into(self) -> AccountSharedData {
+impl From<EphemeralAta> for AccountSharedData {
+    fn from(val: EphemeralAta) -> Self {
         let token_account = SplAccount {
-            mint: self.mint,
-            owner: self.owner,
-            amount: self.amount,
+            mint: val.mint,
+            owner: val.owner,
+            amount: val.amount,
             delegate: COption::None,
             state: AccountState::Initialized,
             is_native: COption::None,
             delegated_amount: 0,
             close_authority: COption::None,
         };
         // ... rest unchanged
     }
 }

3458-3460: Fix confusing double-negation logic.

Line 3458: if !record.owner.ne(&EATA_PROGRAM_ID) is equivalent to if record.owner == EATA_PROGRAM_ID, which seems backwards. The delegation record's owner field typically stores the original account owner (wallet), not a program ID. Clarify the intended logic.

If you're checking that the record owner is NOT the eATA program:

-        if !record.owner.ne(&EATA_PROGRAM_ID) {
+        if record.owner == EATA_PROGRAM_ID {
             return None;
         }

Or if you meant to validate something else, please clarify with a comment explaining what record.owner represents in this context.


3462-3467: Critical: Buffer length check is insufficient.

Line 3462 checks data.len() < 40, but line 3467 reads data[64..72] for the amount. If data length is between 40 and 71 bytes, this will panic with an index out of bounds error.

-        if data.len() < 40 {
+        if data.len() < 72 {
             return None;
         }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00d6f19 and 29f678b.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • Cargo.toml (1 hunks)
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs (10 hunks)
  • magicblock-chainlink/src/testing/eatas.rs (1 hunks)
  • magicblock-core/src/lib.rs (1 hunks)
  • magicblock-core/src/token_programs.rs (1 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (3 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (15)
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.

Applied to files:

  • magicblock-core/src/lib.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-core/src/token_programs.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/testing/eatas.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
🧬 Code graph analysis (5)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (18-24)
  • derive_eata (38-44)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (1)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (18-24)
  • derive_eata (38-44)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (18-24)
  • derive_eata (38-44)
magicblock-core/src/token_programs.rs (1)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
  • try_derive_eata_address_and_bump (3399-3406)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
magicblock-core/src/token_programs.rs (1)
  • try_derive_eata_address_and_bump (47-55)
🔇 Additional comments (6)
magicblock-core/src/lib.rs (1)

18-18: LGTM! Token programs module properly exported.

The new module declaration correctly exposes the token program utilities for use across the crate.

programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (1)

455-618: ATA→eATA remapping tests look solid.

Both test cases correctly:

  • Create delegated SPL ATA accounts with proper layout
  • Execute the full schedule→accept flow
  • Verify the committed pubkey remaps to the derived eATA
  • Check undelegation status where applicable

The test coverage aligns well with the MIMD-0013 implementation.

magicblock-chainlink/src/testing/eatas.rs (1)

1-3: Good use of re-exports to avoid constant duplication.

Re-exporting from magicblock_core::token_programs is the right approach to avoid duplicating program ID constants across files.

magicblock-core/src/token_programs.rs (1)

1-55: Well-structured token program utilities module.

The implementation correctly:

  • Defines program IDs using the pubkey! macro for compile-time validation
  • Implements standard Solana PDA derivation patterns for ATAs and eATAs
  • Provides both infallible (find_program_address) and fallible (try_find_program_address) variants
  • Uses appropriate seed combinations per ATA and eATA specifications
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)

3331-3393: ATA detection logic is well-implemented.

The is_ata function correctly:

  • Validates the account owner is either spl-token or spl-token-2022
  • Safely extracts mint and owner from the account data
  • Derives the expected ATA address using proper seeds
  • Returns Some(AtaInfo) only when the pubkey matches the derived address
Cargo.toml (1)

191-192: Both spl-token v7.0 and spl-token-2022 v7.0 exist and are safe to use.

Version 7.0.0 of spl-token was released on 2024-11-01, and version 7.0.0 of spl-token-2022 was released on 2025-01-17. Both are stable releases. Token-2022 has undergone security audits from Halborn, Zellic, NCC, Trail of Bits, and OtterSec, and no critical security vulnerabilities were found in available documentation.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (2)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)

1114-1196: eATA subscription cleanup is still incomplete.

The existing review comment on lines 1109-1196 remains valid. eATA accounts are subscribed to at line 1124 but are never tracked for cleanup. When:

  1. The eATA doesn't exist (maybe_eata_account is None)
  2. The delegation record fetch fails or returns None
  3. The eATA is not delegated to this validator
  4. maybe_into_ata returns None

...the eATA subscription remains active unnecessarily.

Consider tracking eATA pubkeys and cancelling subscriptions in the fallback paths where the eATA data is not used.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)

184-208: Consider extracting the ATA→eATA remapping to a helper function.

Per previous review feedback from taco-paco, this remapping logic should also apply to ScheduleBaseIntent/process_schedule_base_intent. Extracting to a shared helper would ensure consistency:

fn remap_ata_to_eata_if_delegated(
    pubkey: &Pubkey,
    account: &impl ReadableAccount,
) -> Pubkey {
    if account.delegated() {
        if let Some(ata) = is_ata(pubkey, account) {
            return derive_eata(&ata.owner, &ata.mint);
        }
    }
    *pubkey
}

The current logic is correct, but consolidating it would prevent divergence between commit paths.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29f678b and 235b4a6.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs (10 hunks)
  • magicblock-core/Cargo.toml (1 hunks)
  • magicblock-core/src/token_programs.rs (1 hunks)
  • programs/magicblock/Cargo.toml (1 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (3 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (12)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-core/Cargo.toml
  • programs/magicblock/Cargo.toml
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
🧬 Code graph analysis (3)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2)
magicblock-chainlink/src/testing/eatas.rs (1)
  • create_ata_account (10-33)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (21-27)
  • derive_eata (41-47)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
magicblock-core/src/token_programs.rs (2)
  • derive_eata (41-47)
  • is_ata (72-120)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
magicblock-core/src/token_programs.rs (2)
  • is_ata (72-120)
  • try_derive_eata_address_and_bump (50-58)
🔇 Additional comments (16)
programs/magicblock/Cargo.toml (1)

27-27: LGTM!

Adding magicblock-chainlink as a dev-dependency with the dev-context feature is appropriate for enabling test utilities related to the new ATA/eATA functionality.

magicblock-core/Cargo.toml (1)

25-26: LGTM!

Adding spl-token and spl-token-2022 workspace dependencies is necessary for the new token programs module to support both legacy and Token-2022 program owners.

magicblock-core/src/token_programs.rs (4)

9-18: LGTM! Program ID constants are well-defined.

The SPL Token, Associated Token, and eATA program IDs are clearly documented and use the canonical addresses.


21-58: LGTM! PDA derivation functions are correctly implemented.

The ATA derivation follows the standard SPL Associated Token Account seeds [owner, token_program, mint], and the eATA derivation uses the simpler [owner, mint] seeds. Both try_* variants properly expose the bump seed for callers that need it.


72-120: LGTM! ATA detection logic is robust.

The is_ata function correctly:

  • Validates ownership by SPL Token or Token-2022 programs
  • Safely parses mint and owner from account data with proper length checks
  • Uses the correct PDA derivation seeds including the actual token program owner
  • Returns structured AtaInfo for downstream use

176-200: LGTM! eATA to ATA projection logic is well-implemented.

The MaybeIntoAta implementation:

  • Correctly guards conversion to only proceed when owner_program matches EATA_PROGRAM_ID
  • Uses safe parsing with proper buffer length validation (72 bytes minimum)
  • Cleanly constructs the EphemeralAta and converts to AccountSharedData
magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)

14-17: LGTM! Imports for ATA/eATA utilities are properly added.

The imports from magicblock_core::token_programs provide the necessary helpers for ATA detection, eATA derivation, and conversion.


718-724: LGTM! ATA detection is correctly integrated into the account classification flow.

ATAs are properly detected after executable/native loader checks and before falling back to plain accounts, ensuring they receive special eATA handling.


1165-1178: LGTM! Delegation check and ATA projection logic are correct.

The logic correctly:

  1. Validates that the delegation authority is this validator (or confined/default)
  2. Passes deleg.owner (the original account owner from the delegation record) to maybe_into_ata
  3. Only projects eATA data to ATA form when the delegation record indicates eATA ownership
  4. Sets the delegated flag on the resulting account

3332-3333: LGTM!

The comment helpfully documents that local helpers were refactored to magicblock_core::token_programs.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)

3-3: LGTM!

Import of derive_eata from the centralized token programs module is correct.


188-202: Verify: All delegated ATAs are remapped to eATAs unconditionally.

The logic remaps every delegated ATA to its corresponding eATA address for commit/undelegate operations. This assumes:

  1. All delegated ATAs should commit through the eATA program
  2. The eATA address exists on-chain (or the commit will handle creation)

If there are scenarios where ATAs are delegated directly (not through eATA flow), this remapping could cause issues. Please confirm this behavior aligns with MIMD 0013 requirements.

programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (4)

258-266: LGTM!

The imports cleanly leverage the shared testing utilities (create_ata_account) and token program helpers (derive_ata, derive_eata) for the new remapping tests.


268-277: LGTM!

Clean refactoring that reuses the shared create_ata_account helper. The conversion to AccountSharedData and delegation flag setting are straightforward.


522-529: LGTM!

The assertion correctly verifies that the committed pubkey is remapped from the original ATA to the derived eATA, validating the core MIMD-0013 remapping behavior.


604-613: LGTM!

Assertions correctly verify both the ATA→eATA remapping and that the undelegation flag is set, comprehensively covering the commit-and-undelegate flow.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 235b4a6 and 7ee8a1f.

📒 Files selected for processing (2)
  • magicblock-chainlink/src/testing/eatas.rs (1 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-12-17T12:46:29.027Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • magicblock-chainlink/src/testing/eatas.rs
🧬 Code graph analysis (2)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2)
magicblock-chainlink/src/testing/eatas.rs (1)
  • create_ata_account (11-34)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (21-27)
  • derive_eata (41-47)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (21-27)
  • derive_eata (41-47)
🔇 Additional comments (5)
magicblock-chainlink/src/testing/eatas.rs (2)

1-9: LGTM! Clean consolidation of shared token program utilities.

Re-exporting from magicblock_core::token_programs properly addresses the previous duplication concerns and centralizes the ATA/eATA derivation logic.


11-34: LGTM! Correct SPL token account construction.

The function properly uses SplAccount::pack to serialize a valid SPL token account structure and correctly sets the owner to SPL_TOKEN_PROGRAM_ID.

programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (3)

258-277: LGTM! Clean helper reusing shared utilities.

The helper make_delegated_spl_ata_account properly leverages the shared create_ata_account helper from magicblock_chainlink::testing::eatas, avoiding duplication and ensuring consistent account structure.


450-529: LGTM! Solid test for ATA→eATA remapping.

The test correctly:

  • Derives both ATA and expected eATA addresses from the same wallet/mint
  • Constructs a delegated SPL-ATA account at the ATA address
  • Schedules and accepts a commit
  • Verifies the committed pubkey is the derived eATA

This properly validates the MIMD-0013 remapping behavior.


531-613: LGTM! Comprehensive undelegation + remapping test.

The test extends the remapping verification to include the undelegation flow, correctly asserting both:

  • The pubkey remaps to eATA
  • is_undelegate() returns true

Good coverage of the combined behavior.

GabrielePicco and others added 2 commits December 17, 2025 15:37
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)

410-424: Consider adding logging for remapping events.

The remapping logic is correct and consistent across both Standalone and WithBaseActions branches. However, unlike process_schedule_commit.rs (lines 192-197), there's no logging when remapping occurs here. Since context.invoke_context is available, consider adding similar logging for debugging consistency:

if remapped != pubkey {
    ic_msg!(
        context.invoke_context,
        "CommitType: remapping ATA {} -> eATA {} for commit",
        pubkey,
        remapped
    );
}

This would improve observability across both commit paths.

Also applies to: 444-458

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ee8a1f and 1aae4b2.

📒 Files selected for processing (4)
  • magicblock-chainlink/src/testing/eatas.rs (1 hunks)
  • programs/magicblock/src/magic_scheduled_base_intent.rs (3 hunks)
  • programs/magicblock/src/schedule_transactions/mod.rs (1 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/testing/eatas.rs
  • programs/magicblock/src/schedule_transactions/mod.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
📚 Learning: 2025-12-17T12:46:29.027Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-chainlink/src/testing/eatas.rs
  • programs/magicblock/src/schedule_transactions/mod.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • magicblock-chainlink/src/testing/eatas.rs
🧬 Code graph analysis (4)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
programs/magicblock/src/schedule_transactions/mod.rs (1)
  • remap_ata_to_eata_if_delegated (52-75)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
programs/magicblock/src/schedule_transactions/mod.rs (1)
  • remap_ata_to_eata_if_delegated (52-75)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (142-145)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (21-27)
  • derive_eata (41-47)
programs/magicblock/src/schedule_transactions/mod.rs (2)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (21-27)
  • derive_eata (41-47)
magicblock-magic-program-api/src/args.rs (1)
  • data (26-28)
🔇 Additional comments (7)
magicblock-chainlink/src/testing/eatas.rs (1)

1-9: LGTM - Clean re-exports and imports.

The re-exports from magicblock_core::token_programs and standard imports are well-organized. The previous duplication concerns have been properly addressed by using shared definitions from the core module.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (3)

39-39: LGTM!

The documentation comment usefully points developers to the centralized location for token program utilities.


183-198: LGTM! Past feedback addressed.

The remapping logic correctly uses the extracted helper function remap_ata_to_eata_if_delegated and logs remapping events for debugging. This addresses taco-paco's suggestion to extract the logic into a reusable helper function.

Based on learnings from taco-paco's review feedback.


202-202: Correct usage of remapped pubkey.

The target_pubkey (potentially remapped to eATA) is correctly used when constructing the CommittedAccount, ensuring that delegated ATAs are committed to their corresponding eATAs.

programs/magicblock/src/magic_scheduled_base_intent.rs (1)

22-22: LGTM!

The import of remap_ata_to_eata_if_delegated is correct and enables ATA→eATA remapping in the args-based commit path.

programs/magicblock/src/schedule_transactions/mod.rs (2)

42-50: LGTM!

The comment clearly documents the helper's purpose, and the necessary imports are correctly included.


52-75: LGTM! Correct and defensive implementation.

The function correctly implements ATA→eATA remapping with appropriate guards:

  • Validates delegation and SPL Token ownership
  • Correctly parses mint (bytes 0-32) and owner (bytes 32-64) per SPL Token account layout
  • Derives and validates ATA before remapping to eATA
  • Falls back safely to the original pubkey on any validation failure

The ATA derivation check (ata == *pubkey) provides implicit validation that the account structure is as expected, making the implementation robust against edge cases.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
magicblock-api/src/domain_registry_manager.rs (1)

1-11: Consider extracting the program ID conversion.

The pattern ID.to_bytes().into() appears multiple times (lines 107, 175). Consider defining a constant or helper to reduce repetition:

use mdp::ID;
// Near imports or as a lazy_static/const
fn mdp_program_id() -> Pubkey {
    ID.to_bytes().into()
}

This is a minor suggestion for improved readability.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1aae4b2 and 00374ce.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • Cargo.toml (1 hunks)
  • magicblock-api/src/domain_registry_manager.rs (6 hunks)
  • magicblock-api/src/magic_validator.rs (1 hunks)
  • magicblock-chainlink/Cargo.toml (1 hunks)
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs (8 hunks)
  • magicblock-chainlink/src/testing/eatas.rs (1 hunks)
  • magicblock-chainlink/src/testing/mod.rs (1 hunks)
  • magicblock-committor-service/src/intent_execution_manager/db.rs (1 hunks)
  • magicblock-processor/src/lib.rs (1 hunks)
  • magicblock-processor/src/scheduler/coordinator.rs (3 hunks)
  • programs/magicblock/Cargo.toml (1 hunks)
  • programs/magicblock/src/magic_scheduled_base_intent.rs (3 hunks)
  • programs/magicblock/src/schedule_transactions/mod.rs (2 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2 hunks)
  • test-integration/Cargo.toml (1 hunks)
🧰 Additional context used
🧠 Learnings (21)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • magicblock-processor/src/lib.rs
  • magicblock-api/src/magic_validator.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • magicblock-processor/src/lib.rs
  • magicblock-api/src/magic_validator.rs
  • magicblock-api/src/domain_registry_manager.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-processor/src/scheduler/coordinator.rs
  • programs/magicblock/src/schedule_transactions/mod.rs
  • magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • magicblock-processor/src/lib.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • magicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • magicblock-processor/src/lib.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • magicblock-api/src/magic_validator.rs
  • programs/magicblock/Cargo.toml
  • test-integration/Cargo.toml
  • Cargo.toml
  • magicblock-chainlink/Cargo.toml
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-17T12:46:29.027Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:29.027Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
  • programs/magicblock/src/schedule_transactions/mod.rs
  • magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-10-26T16:53:29.820Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:134-0
Timestamp: 2025-10-26T16:53:29.820Z
Learning: In magicblock-chainlink/src/remote_account_provider/mod.rs, the `Endpoint::separate_pubsub_url_and_api_key()` method uses `split_once("?api-key=")` because the api-key parameter is always the only query parameter right after `?`. No additional query parameter parsing is needed for this use case.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-13T09:38:43.804Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/locks.rs:64-102
Timestamp: 2025-11-13T09:38:43.804Z
Learning: In magicblock-processor's TransactionScheduler (scheduler/mod.rs line 59), the executor count is clamped to MAX_SVM_EXECUTORS (63) at initialization time, and executor IDs are assigned sequentially from 0 to count-1. This architectural guarantee ensures that executor IDs used in the bitmask-based AccountLock (scheduler/locks.rs) will always be within valid bounds for bit shifting operations, making runtime bounds checks unnecessary.

Applied to files:

  • magicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-11-04T10:53:50.922Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/locks.rs:110-122
Timestamp: 2025-11-04T10:53:50.922Z
Learning: In magicblock-processor, the TransactionScheduler runs in a single, dedicated thread and will always remain single-threaded. The `next_transaction_id()` function in scheduler/locks.rs uses `unsafe static mut` which is safe given this architectural guarantee.

Applied to files:

  • magicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-10-21T10:34:59.140Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-accounts-db/src/lib.rs:63-72
Timestamp: 2025-10-21T10:34:59.140Z
Learning: In magicblock-validator, the AccountsDb "stop-the-world" synchronizer is managed at the processor/executor level, not at the AccountsDb API level. Transaction executors in magicblock-processor hold a read lock (sync.read()) for the duration of each slot and release it only at slot boundaries, ensuring all account writes happen under the read lock. Snapshot operations acquire a write lock, blocking until all executors release their read locks. This pattern ensures mutual exclusion between writes and snapshots without requiring read guards in AccountsDb write APIs.

Applied to files:

  • magicblock-processor/src/scheduler/coordinator.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • magicblock-chainlink/src/testing/mod.rs
  • magicblock-chainlink/src/testing/eatas.rs
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.

Applied to files:

  • programs/magicblock/Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • Cargo.toml
🧬 Code graph analysis (5)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
programs/magicblock/src/schedule_transactions/mod.rs (1)
  • remap_ata_to_eata_if_delegated (50-73)
magicblock-api/src/magic_validator.rs (1)
test-integration/test-magicblock-api/tests/test_claim_fees.rs (1)
  • validator_keypair (23-29)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2)
magicblock-chainlink/src/testing/eatas.rs (1)
  • create_ata_account (11-34)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (21-27)
  • derive_eata (41-47)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
magicblock-core/src/token_programs.rs (2)
  • is_ata (72-120)
  • try_derive_eata_address_and_bump (50-58)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (21-27)
  • derive_eata (41-47)
🔇 Additional comments (32)
magicblock-processor/src/scheduler/coordinator.rs (1)

154-154: LGTM! Clean refactoring of iterator usage.

The refactoring correctly moves .enumerate() from the iterator creation to the specific usage sites where indices are needed. This approach is more flexible and makes the final loop (lines 217-218) cleaner since it doesn't need to destructure and ignore the index. The change from passing acc by value to &acc by reference at line 218 is more idiomatic given that clear_account_contention expects &Pubkey.

Also applies to: 157-157, 202-202, 217-219

magicblock-api/src/magic_validator.rs (1)

528-536: LGTM!

The conversion of validator_keypair.pubkey() to bytes aligns with the updated RecordV0 structure that now stores the identity as a byte sequence, consistent with the byte-oriented handling introduced across the codebase for MIMD 0013.

magicblock-api/src/domain_registry_manager.rs (6)

60-74: LGTM!

The conversion pda.to_bytes().into() is correctly applied since validator_info.pda() returns a type from the mdp crate that requires explicit conversion to solana_pubkey::Pubkey for send_instruction.


92-103: LGTM!

Consistent conversion pattern as in register().


105-108: LGTM!

The conversion of ID.to_bytes().into() is necessary because mdp::ID requires explicit conversion to solana_pubkey::Pubkey for find_program_address. The temporary lifetime is correctly extended by the reference.


110-127: LGTM!

The conversion logic is correct:

  • pda comes from Self::get_pda() which already returns solana_pubkey::Pubkey, so no conversion is needed for send_instruction
  • payer.pubkey().to_bytes().into() is required because Unregister instruction expects a bytes-based identity type

129-151: LGTM!

The conversion validator_info.pda().0.to_bytes().into() correctly transforms the mdp crate's PDA type to solana_pubkey::Pubkey for the fetch_validator_info call.


174-178: LGTM!

The conversion ID.to_bytes().into() correctly transforms mdp::ID to solana_pubkey::Pubkey for the Instruction::new_with_borsh program ID parameter.

magicblock-processor/src/lib.rs (2)

20-28: LGTM: Feature flag activation is correct.

The activation of disable_rent_fees_collection on line 23 correctly justifies the removal of the rent collector instance. The feature flags are well-documented and appropriately activated for ephemeral rollup operations.


45-54: The change to set rent_collector to None is correct and safe. The codebase uses idiomatic Rust Option handling (.as_ref().map().and_then()) that gracefully handles the None case without unsafe unwraps or panics. This approach is consistent with the disable_rent_fees_collection feature flag logic.

magicblock-chainlink/Cargo.toml (1)

40-41: LGTM!

The workspace dependencies for spl-token and spl-token-2022 are correctly added to support the new ATA/eATA handling logic in the chainlink module.

magicblock-committor-service/src/intent_execution_manager/db.rs (1)

54-63: LGTM!

The simplification removing the explicit .into_iter() is idiomatic—VecDeque::extend accepts any IntoIterator, and Vec<T> satisfies that directly.

programs/magicblock/Cargo.toml (1)

44-44: LGTM!

The dev-dependency on magicblock-chainlink with dev-context feature is correctly scoped to enable the testing utilities (create_ata_account, etc.) used by the new ATA/eATA remapping tests.

programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (3)

255-275: LGTM!

The helper make_delegated_spl_ata_account correctly reuses the shared create_ata_account utility, avoiding code duplication while properly setting the delegated flag for test scenarios.


448-527: LGTM!

The test correctly validates the ATA→eATA remapping flow: it sets up a delegated SPL Token ATA, schedules a commit, and verifies the committed pubkey is remapped to the corresponding eATA derived from the same wallet owner and mint.


529-611: LGTM!

The test correctly validates the combined ATA→eATA remapping and undelegation flow, asserting both the pubkey remapping and the is_undelegate() flag.

test-integration/Cargo.toml (1)

92-92: Exact version pinning confirmed as intentional; spl-token 7.0.0 is stable and published.

The exact version pin =7.0 (spl-token 7.0.0, published Nov 2024) locks the dependency for reproducible builds. Note that version 9.0.0 is available on crates.io; ensure this older version is intentional for workspace compatibility rather than oversight.

Cargo.toml (1)

204-206: LGTM! Clean workspace dependency additions.

The SPL Token dependencies are properly declared at the workspace level with consistent versioning (7.0 for both crates).

magicblock-chainlink/src/testing/mod.rs (1)

10-11: LGTM! Test utilities properly exposed.

The new eatas module is correctly feature-gated for test/dev contexts, consistent with other testing modules.

programs/magicblock/src/magic_scheduled_base_intent.rs (3)

21-21: LGTM! Remapping helper properly imported.

The remap_ata_to_eata_if_delegated import enables consistent ATA-to-eATA remapping across schedule paths.


410-422: LGTM! Consistent ATA remapping applied in Standalone path.

The remapping logic correctly:

  • Derives the target pubkey (ATA or eATA) based on delegation status
  • Uses the remapped key for the CommittedAccount
  • Applies owner normalization after remapping

This matches the design in process_schedule_commit.rs.


444-457: LGTM! Consistent ATA remapping applied in WithBaseActions path.

The remapping logic is identical to the Standalone path, ensuring consistent behavior across both commit types.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)

36-36: Good documentation of centralized token program constants.

The comment clarifies that program IDs and derivation helpers are centralized in magicblock-core::token_programs, improving maintainability.


180-199: LGTM! ATA-to-eATA remapping correctly implemented.

The remapping logic:

  • Calls remap_ata_to_eata_if_delegated to compute the target pubkey
  • Logs the remapping when it occurs (useful for debugging)
  • Uses the remapped pubkey for the committed account

This aligns with the schedule_transactions module design and ensures delegated ATAs are committed as eATAs.

programs/magicblock/src/schedule_transactions/mod.rs (2)

44-48: LGTM! Token program utilities properly imported.

The imports bring in the necessary helpers from magicblock-core::token_programs for ATA/eATA derivation.


50-73: SPL Token account data layout is correct, but function only supports legacy spl-token.

The byte layout assumption is verified and correct (bytes 0-32 contain mint pubkey, bytes 32-64 contain owner pubkey). This layout is consistent with how the codebase parses SPL Token accounts elsewhere and is validated by the test suite.

However, remap_ata_to_eata_if_delegated only checks account.owner() == &SPL_TOKEN_PROGRAM_ID and does not support spl-token-2022. The parallel is_ata function in the same codebase handles both token programs. If spl-token-2022 support is needed, add a check for spl_token_2022::id() similar to the is_ata function (magicblock-core/src/token_programs.rs:78-80).

magicblock-chainlink/src/testing/eatas.rs (2)

1-9: LGTM! Clean imports and re-exports.

The module properly imports necessary types and re-exports token program utilities for test use.


11-34: LGTM! Standard SPL token account creation.

The function correctly:

  • Initializes a standard SPL Token account structure
  • Uses Pack trait for proper serialization
  • Calculates lamports based on account size
  • Sets appropriate owner (SPL_TOKEN_PROGRAM_ID)

This is a solid test helper for creating ATA accounts.

magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)

14-17: LGTM! Token program utilities properly imported.

The new imports enable ATA detection, eATA derivation, and eATA-to-ATA conversion functionality.


670-740: LGTM! ATA detection and collection correctly integrated.

The fold accumulator is properly extended to:

  • Add atas to the tuple (lines 670, 672, 678, 739)
  • Detect ATAs using is_ata (line 718)
  • Collect ATA accounts with their metadata (lines 719-724)

This maintains the existing flow while adding ATA-specific handling.


760-766: LGTM! Logging updated to include ATA accounts.

The debug logging now includes the atas collection, providing visibility into ATA handling during fetch operations.


1109-1196: Verify eATA subscription lifecycle and conversion safety.

The ATA/eATA handling implements a sophisticated flow:

  1. Subscription management (lines 1118-1138): Subscribes to both ATA and eATA. Per learnings, eATA subscriptions are intentionally NOT cancelled even when conversion fails, to watch for future creation/delegation.

  2. Conversion logic (lines 1154-1179):

    • Fetches delegation record for the eATA
    • Checks if delegated to validator (including default/confined case)
    • Converts eATA to ATA-like structure using maybe_into_ata
    • Marks as delegated and captures commit frequency
  3. Fallback behavior (lines 1151-1153, 1188-1193): On errors, logs warnings but continues processing other accounts.

Potential concerns:

  • The eATA subscriptions accumulate (never cancelled). Verify this doesn't cause memory/subscription limit issues at scale.
  • When maybe_into_ata returns None, the original ata_account is used (line 1183). Ensure this is the intended fallback.

Based on learnings, this behavior is intentional. However, please verify:

#!/bin/bash
# Description: Verify subscription management and conversion behavior

# Check if there are subscription limits or cleanup mechanisms
rg -n "max.*subscription|subscription.*limit|cleanup.*subscription" --type rust -C3

# Verify MaybeIntoAta trait and its None return cases
ast-grep --pattern $'impl MaybeIntoAta for $_ {
  $$$
  fn maybe_into_ata($$$) -> Option<$_> {
    $$$
  }
  $$$
}'

# Check if ata_account is intended as fallback when eATA conversion fails
rg -n "account_to_clone.*ata_account|ata.*fallback" --type rust -C5

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00374ce and 37debe7.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • Cargo.toml (3 hunks)
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs (8 hunks)
  • magicblock-core/src/token_programs.rs (1 hunks)
  • test-integration/Cargo.toml (3 hunks)
  • test-integration/Makefile (1 hunks)
  • test-integration/test-chainlink/src/ixtest_context.rs (1 hunks)
  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-12-17T12:46:36.207Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
  • Cargo.toml
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.

Applied to files:

  • test-integration/test-chainlink/tests/ix_ata_eata_replace.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-11-25T11:07:20.001Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/programs/flexi-counter/src/processor.rs:643-680
Timestamp: 2025-11-25T11:07:20.001Z
Learning: In the compressed delegation architecture, ownership reassignment during undelegation is handled by the delegation program itself, not by the owner program's external undelegate handler. The external undelegate handler (e.g., `process_external_undelegate_compressed` in flexi-counter) is a callback for program-specific cleanup (restoring lamports and data) after the delegation program has already reassigned ownership back to the original owner stored in the CompressedDelegationRecord.

Applied to files:

  • magicblock-chainlink/src/chainlink/fetch_cloner.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • Cargo.toml
  • test-integration/Cargo.toml
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.

Applied to files:

  • Cargo.toml
  • test-integration/Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • Cargo.toml
🧬 Code graph analysis (1)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (1)
magicblock-core/src/token_programs.rs (2)
  • is_ata (72-120)
  • try_derive_eata_address_and_bump (50-58)
🔇 Additional comments (13)
test-integration/Makefile (1)

219-219: LGTM! Good refactoring for maintainability.

Extracting the clippy command into a reusable lint target and having ci-lint depend on it follows the DRY principle and ensures consistency between local and CI linting workflows.

test-integration/test-chainlink/src/ixtest_context.rs (1)

97-98: LGTM!

The simplified constructor call correctly passes the Pubkey reference directly to AccountSharedData::new, removing the unnecessary byte conversion.

test-integration/Cargo.toml (1)

39-62: Dependency updates look appropriate.

The version pinning and feature flags are consistent with workspace-level changes. Using default-features = false with explicit feature selection is good practice for controlling the dependency footprint.

Also applies to: 92-92

Cargo.toml (1)

204-206: Workspace SPL token dependencies added correctly.

The addition of spl-token and spl-token-2022 as workspace dependencies enables consistent version usage across the codebase for the new ATA/eATA handling functionality.

test-integration/test-chainlink/tests/ix_ata_eata_replace.rs (2)

1-76: Well-structured test coverage for ATA/eATA replacement behavior.

The test correctly:

  • Derives ATA and eATA addresses using the helper functions
  • Sets up delegation records targeting the test validator
  • Verifies all relevant token account fields after ensure_accounts
  • Confirms the delegated() flag is set appropriately

Good coverage of the happy path for delegated ATA replacement.


78-109: Good negative test case.

Correctly verifies that without a delegation record, the original ATA data is preserved and the account is not marked as delegated.

magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)

1114-1139: Well-structured parallel ATA/eATA fetch implementation.

The implementation correctly:

  • Subscribes to both ATA and derived eATA before fetching (ensuring updates are captured)
  • Uses JoinSet for efficient parallel processing
  • Computes effective_slot consistently with other fetch paths
  • Per learnings, intentionally keeps eATA subscriptions active for future creation/delegation detection

1186-1191: Error handling uses warn-level logging rather than aborting.

Unlike delegation record resolution failures which abort the entire operation, ATA/eATA resolution failures only log warnings and skip the account. This asymmetric behavior may be intentional for resilience (ATAs are supplementary to the main account flow), but worth confirming this is the desired behavior.


670-741: ATA detection integrated cleanly into the account categorization fold.

The addition of the atas accumulator follows the existing pattern for other account types (not_found, plain, owned_by_deleg, programs). The is_ata() check is placed after executable detection, ensuring programs aren't misclassified.


14-17: Token program imports added appropriately.

The imports from magicblock_core::token_programs provide the necessary utilities for ATA detection and eATA derivation.

magicblock-core/src/token_programs.rs (3)

1-18: LGTM: Clean module structure and well-documented constants.

The imports are appropriate for the token program helpers, and the program ID constants are clearly documented with descriptive comments.


60-120: LGTM: Robust ATA validation logic.

The is_ata function properly validates Associated Token Accounts by:

  • Supporting both SPL Token and Token-2022 programs (lines 78-79)
  • Parsing account data with safe error handling (lines 88-100)
  • Verifying the PDA derivation matches the actual account address (lines 103-119)

This defense-in-depth approach ensures the account is a legitimate ATA rather than just trusting the data layout.


176-200: LGTM: Safe eATA to ATA conversion with proper validation.

The MaybeIntoAta implementation correctly:

  • Guards on the EATA_PROGRAM_ID owner (line 181)
  • Validates minimum data length (line 187)
  • Uses safe byte parsing with try_into().ok()? pattern (lines 190-192)
  • Returns None on any parsing failure

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37debe7 and 53461a0.

📒 Files selected for processing (6)
  • magicblock-chainlink/src/testing/eatas.rs (1 hunks)
  • magicblock-core/src/token_programs.rs (1 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2 hunks)
  • test-integration/Makefile (1 hunks)
  • test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rs (1 hunks)
  • test-integration/test-tools/src/integration_test_context.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • magicblock-chainlink/src/testing/eatas.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rs
  • magicblock-chainlink/src/testing/eatas.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • magicblock-chainlink/src/testing/eatas.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-12-17T12:46:36.207Z
Learnt from: GabrielePicco
Repo: magicblock-labs/magicblock-validator PR: 738
File: magicblock-chainlink/src/chainlink/fetch_cloner.rs:1109-1196
Timestamp: 2025-12-17T12:46:36.207Z
Learning: In magicblock-chainlink/src/chainlink/fetch_cloner.rs, eATA account subscriptions are intentionally NOT cancelled even when the eATA doesn't exist or delegation conversion fails. The subscriptions are kept active to watch for future creation or delegation of eATA accounts (per maintainer GabrielePicco).

Applied to files:

  • magicblock-chainlink/src/testing/eatas.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • magicblock-chainlink/src/testing/eatas.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • magicblock-core/src/token_programs.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.

Applied to files:

  • magicblock-core/src/token_programs.rs
🧬 Code graph analysis (2)
magicblock-chainlink/src/testing/eatas.rs (1)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (28-34)
  • derive_eata (62-68)
programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (2)
magicblock-chainlink/src/testing/eatas.rs (1)
  • create_ata_account (16-39)
magicblock-core/src/token_programs.rs (2)
  • derive_ata (28-34)
  • derive_eata (62-68)
🪛 checkmake (0.2.2)
test-integration/Makefile

[warning] 221-221: Missing required phony target "all"

(minphony)


[warning] 221-221: Missing required phony target "clean"

(minphony)


[warning] 221-221: Missing required phony target "test"

(minphony)

🔇 Additional comments (14)
test-integration/Makefile (3)

213-214: LGTM! Clean linting target implementation.

The new lint target properly runs clippy across all targets with warnings treated as errors, which is a standard best practice for maintaining code quality.


219-219: LGTM! Good refactoring to eliminate duplication.

The ci-lint target now cleanly delegates to the lint target, ensuring consistent linting behavior between CI and local development without command duplication.


221-263: Previous concern addressed - .PHONY declaration is now correct.

The lint target is now properly included in the .PHONY declaration (line 223), which prevents Make from skipping the target if a file named lint exists in the directory. This addresses the concern raised in the previous review.

test-integration/test-ledger-restore/tests/14_restore_with_new_keypair.rs (1)

4-7: LGTM!

The unused IntegrationTestContext import is correctly removed. The test obtains its context instance from setup_validator_with_local_remote() and doesn't need the type imported directly.

magicblock-core/src/token_programs.rs (5)

1-18: LGTM: Clean imports and well-defined program ID constants.

The imports are appropriate, and the three program ID constants use the compile-time pubkey! macro correctly. The inline comments clearly identify each program.


20-86: LGTM: Well-documented derivation helpers with correct PDA seeds.

The four public derivation functions have proper rustdoc comments and use the correct seed patterns:

  • ATA: [owner, SPL_TOKEN_PROGRAM_ID, mint] with ASSOCIATED_TOKEN_PROGRAM_ID
  • eATA: [owner, mint] with EATA_PROGRAM_ID

The try_* variants appropriately return Option<(Pubkey, u8)> for fallible derivation.


88-148: LGTM: Robust ATA detection with proper validation.

The is_ata function correctly:

  • Supports both spl-token and spl-token-2022 program owners
  • Validates minimum data length (64 bytes for mint + owner)
  • Parses the SPL Token account layout (mint at 0..32, owner at 32..64)
  • Derives the expected ATA address and compares it to the actual pubkey

The use of early returns with None for validation failures is appropriate.


174-202: Conversion logic is correct; note past discussions on .expect() and Rent::default().

The From<EphemeralAta> implementation correctly constructs an SplAccount and packs it to bytes. Past reviews raised concerns about:

  1. Line 189: .expect("pack spl token account") could panic in public API
  2. Line 190: Rent::default() may not reflect actual on-chain rent values

These concerns were discussed previously. The conversion logic itself is sound for test/ephemeral use cases.

Context from past reviews

Based on learnings, the maintainer indicated .expect() is acceptable in tests, though this code is in a public API module. If this conversion is intended only for test/ephemeral contexts, consider adding a doc comment clarifying that constraint.


204-228: LGTM: Clean eATA→ATA projection with proper layout parsing.

The MaybeIntoAta implementation correctly:

  • Guards against non-eATA accounts (line 209)
  • Validates minimum data length of 72 bytes (owner + mint + amount)
  • Safely parses the eATA layout using try_into().ok()?
  • Converts to AccountSharedData via the EphemeralAta type

This implementation enables the ATA/eATA remapping functionality tested in the schedule/commit tests.

programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs (3)

255-274: LGTM: Clean test helper for delegated ATA accounts.

The make_delegated_spl_ata_account helper correctly:

  • Reuses create_ata_account from the test utilities for proper SPL Token layout
  • Converts to AccountSharedData
  • Sets the delegated flag

This provides a clean way to construct test accounts with the correct ATA structure for remapping tests.


447-526: LGTM: Comprehensive test for ATA→eATA remapping in schedule-commit flow.

The test correctly verifies that:

  1. A delegated SPL Token ATA account is used as a committee member
  2. The schedule-commit instruction accepts the ATA pubkey
  3. After acceptance, the committed pubkey is remapped to the corresponding eATA address

The test assertions at lines 522-525 confirm the remapping logic works as expected for the standard commit flow.


528-610: LGTM: Test coverage for ATA→eATA remapping with undelegation.

This test verifies the remapping logic also works correctly for the schedule-commit-and-undelegate flow. The additional assertion at line 609 confirms the is_undelegate() flag is properly set alongside the eATA remapping.

Together with the previous test, this provides comprehensive coverage of both commit paths.

magicblock-chainlink/src/testing/eatas.rs (2)

1-9: LGTM: Clean re-exports consolidate constants and types.

The public re-exports from magicblock_core::token_programs provide a convenient testing API while avoiding duplication. This addresses past review concerns about consolidating constants and the EphemeralAta struct.


11-39: LGTM: Well-documented test utility for ATA account creation.

The create_ata_account function correctly constructs an initialized SPL Token account with:

  • Proper field initialization (zero balance, no delegation)
  • Correct serialization via SplAccount::pack
  • Appropriate owner (SPL_TOKEN_PROGRAM_ID)

The rustdoc comment clearly documents the purpose and parameters. Use of .expect() and Rent::default() is acceptable in test utilities.

@GabrielePicco GabrielePicco marked this pull request as draft December 19, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants